package cn.xudy.group.ConfigUtil;

import com.aliyun.oss.ClientConfiguration;
import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClient;
import com.sun.deploy.config.ClientConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * Created by Ulegal on 2017/11/15.
 */
@Component
public class ConfigUtils {


    /**
     *  腾讯云配置
     * @return
     */
    @Bean
    public OSSClient getCOSClient() {
        return this.getOSSClient();
    }


    /**
     * 跨域
     * @return
     */
    @Bean
    public WebMvcConfigurer corsConfigurer() {
        return new WebMvcConfigurerAdapter() {
            @Override
            public void addCorsMappings(CorsRegistry registry) {
                registry.addMapping("/**");
            }
        };
    }


        /**
         * 阿里云OSS对象存储 客户端
         * @return
         */
        public static OSSClient getOSSClient() {
            String endpoint         = "http://oss-cn-beijing.aliyuncs.com";
            String accessKeyId      = "LTAIBcnLKHRH1cl2";
            String accessKeySecret  = "zLIRj3sUwMRTof8YermzdlcNQQwhc1";
            // 创建OSSClient实例
            OSSClient ossClient     = new OSSClient(endpoint, accessKeyId, accessKeySecret);
            return ossClient;
        }




}
